<?php

use yii\widgets\ActiveForm;
use common\enums\WhetherEnum;
use common\enums\StatusEnum;
use addons\AppVersions\common\enums\TypeEnum;

$this->title = '编辑';
$this->params['breadcrumbs'][] = ['label' => 'App版本管理', 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $this->title];
?>

<div class="row">
    <div class="col-lg-12">
        <div class="box">
            <div class="box-header with-border">
                <h3 class="box-title">基本信息</h3>
            </div>
            <?php $form = ActiveForm::begin([
                'fieldConfig' => [
                    'template' => "<div class='col-sm-2 text-right'>{label}</div><div class='col-sm-10'>{input}{hint}{error}</div>",
                ],
            ]); ?>
            <div class="box-body">
                <?= $form->field($model, 'title')->textInput() ?>
                <?= $form->field($model, 'cate_name')->dropDownList($cateMap) ?>
                <?= $form->field($model, 'version')->textInput()->hint('格式要求(必须)：xxxx.xxxx.xxxx, 这个 x 必须为数字前面 0 可忽略，例如：1.0.1') ?>
                <?= $form->field($model, 'package_size')->textInput() ?>
                <?php if ($model->type == TypeEnum::ANDROID){ ?>
                    <?= $form->field($model, 'download_url')->widget(\common\widgets\webuploader\Files::class, [
                        'type' => 'files',
                        'config' => [
                            'pick' => [
                                'multiple' => false,
                            ],
                            'formData' => [
                                // 'drive' => 'oss', // 默认本地 可修改 qiniu/oss 上传
                            ], // 表单参数
                        ],
                    ]); ?>
                <?php } else { ?>
                    <?= $form->field($model, 'download_url')->textInput()->label('AppId')->hint('注意：填写的是你上架后对应的 App Id') ?>
                <?php }; ?>
                <?= $form->field($model, 'is_enforce')->radioList(WhetherEnum::getMap()) ?>
                <?= $form->field($model, 'content')->textarea() ?>
                <?= $form->field($model, 'status')->radioList(StatusEnum::getMap()) ?>
            </div>
            <!-- /.box-body -->
            <div class="box-footer">
                <div class="col-sm-12 text-center">
                    <button class="btn btn-primary" type="submit" onclick="SendForm()">保存</button>
                    <span class="btn btn-white" onclick="history.go(-1)">返回</span>
                </div>
            </div>
            <?php ActiveForm::end(); ?>
        </div>
    </div>
</div>